package com.ibeetl.admin.api.service;

import com.ibeetl.admin.api.dao.TravelVideoDao;
import com.ibeetl.admin.api.entity.Travel_video_list;
import com.ibeetl.admin.api.util.BeanToMap;
import com.ibeetl.admin.core.service.CoreBaseService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
@Transactional
public class TravelVideoService extends CoreBaseService<Travel_video_list> {
    @Resource
    private TravelVideoDao travelVideoDao;

    public List<Travel_video_list> queryByAttractionId(Long attractionId,Long userId) {

        return travelVideoDao.queryByAttractionId(attractionId,userId);

    }

    public Long queryNewIdByAttractionId(Long attractionId,Long userId) {
        List<Long> list = travelVideoDao.queryNewIdByAttractionId(attractionId,userId);
        if(list == null || list.size()<1) return null;
        return list.get(0);
    }

    public List<Travel_video_list> queryByAttsId(Long attsId,Long userId) {

        return travelVideoDao.queryByAttsId(attsId,userId);

    }

    public void delete(Long videoId,int state) {
        travelVideoDao.updateState(videoId,state);
    }

    public boolean saveData(Travel_video_list travel_video) {
        travel_video.setCreateDt(new Date());
        try{
            travelVideoDao.save(BeanToMap.beanToMap(travel_video));
            return true;
        }catch (Exception e){
            return false;
        }
    }


}
